begintownscript;

variables;
short creature_count = 0;
short choice = 0;
short pc_counter = 0;

body;

beginstate 0; //INIT_STATE
	//Loranzo moving around
	if(get_flag(0,3) != 1) {
		set_mobility(31,0);
		}

	//Cockroach
	if(get_flag(0,3) == 1) {
		activate_hidden_group(1);
		}

	//Set guards to level 40
	add_char_to_group(6, 1);
	add_range_to_group(9,14,1);
	add_range_to_group(17, 25, 1);
	set_level(1001, 40);

	set_name(30, "Captain Trechord");
	set_level(30, 60);
	set_name(31, "Loranzo");
	set_level(31, 40);
	set_name(15, "Kindaro");
	if (get_flag(0,0) != 1) {
		message_dialog("As you enter the fort, you notice how the fort's walls merge almost seamlessly with the foot of the cliff, and how the buildings are adapted to the rough terrain. In fact, the architecture looks like it was carved from the cliff itself.","Actually, as the rock face looms higher above you, you start to wonder if the fort was magically shaped from the surrounding stone. You begin to think that the Order's druids are stronger mages than you had thought.");
		set_flag(0,0,1);
		}

	enable_add_chars(1);
	set_crime_tolerance(2);
break;

beginstate 1; //EXIT_STATE

break;

beginstate 2; //START_STATE

break;

beginstate 10; //Guest Quarters
	reset_dialog();
	add_dialog_str(0, "Fort Ouranil's guest quarters seem rather comfortable, and your journey has begun to fatigue you. No one would mind if you rested here for a while...", 0);
	add_dialog_choice(0, "Leave.");
	add_dialog_choice(1, "Rest for a while.");
	choice = run_dialog(1);
	pc_counter = 0;
	if (choice == 2) {
		play_sound(20);
		message_dialog("You take a quick nap, and wake up refreshed and ready to continue your quest.","");
		while (pc_counter <= 5) {
			if(char_ok(pc_counter) == 1) {
				change_char_energy(pc_counter, 200);
				change_char_health(pc_counter, 200);
				}
			pc_counter = pc_counter + 1;
			}
		set_ticks_forward(625);
		}
	else {
		message_dialog("You leave the room undisturbed for the next guests to use it.","");
		block_entry(1);
		}
break;

beginstate 15; //Trechard's office
	if(get_flag(0,2) != 1) {
		reset_dialog();
		message_dialog("You enter the commander's office, and are stunned by the room's design. The entire room is somewhat set into the cliff face, though only the north wall and the ceiling are part of the rock face itself. Only the druids could've done this.","However, what catches your attention is the captain sitting at the oak desk by the window. He's eyeing you with intense distrust for some reason.");
		set_flag(0,2,1);
		}
break;

beginstate 20; //Loranzo's lab
	if(get_flag(0,3) != 1) {
		reset_dialog();
		message_dialog("This room is furnished like an average arcane lab, but it looks more like a landfill. A wizard rushes back and forth, occasionally muttering a spell. He appears rushed and stressed out, and just a bit angry.","For a second it appears that he may have done something important, and he waves his hands dramatically while muttering...");
		//cutscene
		set_total_visibility(1);
		force_instant_terrain_redraw();
		force_view_center(12,30);
		force_instant_terrain_redraw();
		pause(10);
		set_character_pose(31,1);
		force_instant_terrain_redraw();		
		pause(4);
		put_boom_on_char(31,4,0);
		run_animation_sound(90);
		pause(5);
		put_boom_on_space(14,30,3,0);
		run_animation_sound(90);
		activate_hidden_group(1); //bring in the roach
		force_instant_terrain_redraw();
		pause(30);
		set_character_facing(31,6);
		set_character_pose(31,0);
		text_bubble_on_char(31, "NO!!!");
		force_instant_terrain_redraw();
		pause(20);
		erase_text_bubbles();
		text_bubble_on_char(31, "That should've worked!");
		force_instant_terrain_redraw();
		pause(20);
		erase_text_bubbles();
		text_bubble_on_char(31, "Where did I screw up?");
		force_instant_terrain_redraw();
		pause(20);
		erase_text_bubbles();
		force_view_center(char_loc_x(0), char_loc_y(0));
		force_instant_terrain_redraw();
		
		set_total_visibility(0);
		set_mobility(31,1);
		set_flag(0,3,1);
		}
break;

beginstate 25; //Pitiful armory
	if((get_flag(0,4) == 1) && (get_flag(0,6) != 1)) {
		message_dialog("Now that you take a good look at the armory, you realize that Kindaro was telling the truth: the army is running out of supplies. If this is all that the fort has in reserve, then the entire valley is in trouble.","It's becoming even clearer to you that Ephesos must be found soon, so that the invasion of lizards can be stopped.");
		set_flag(0,6,1);
		}
	break;